/*********************************************************************************
 *      Copyright:  (C) 2020 chenxiaohong<www.530990157@qq.com>
 *                  All rights reserved.
 *
 *       Filename:  sqlit_init.c
 *    Description:  This file 
 *                 
 *        Version:  1.0.0(20/06/20)
 *         Author:  chenxiaohong <www.530990157@qq.com>
 *      ChangeLog:  1, Release initial version on "20/06/20 12:26:23"
 *                 
 ********************************************************************************/
#include<stdio.h>
#include<sqlite3.h>
#include"json_client.h"

sqlite3*  sqlite_init(char *json_client)
{
    int               rv;
    char              *errmsg;
    sqlite3           *db;

    rv = sqlite3_open(json_client, &db);
    if(rv != SQLITE_OK)
    {
        printf("open database test.db failed\n");
        return NULL;
    }
    rv = sqlite3_exec(db,"create table JSON (data char);",NULL,NULL,&errmsg);
    if(rv != SQLITE_OK)
    {
        printf("Create or get table failure:%s\n",errmsg);
        return NULL;
    }
    
    if(rv == 1)
    {
        printf("The table already exist,so get it\n");
    }
    else if(rv == 0)
    {
        printf("Create a new table!\n");
    }
    return db;
}
    

